<template>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="ID" prop="objectId" />
      <el-table-column label="分类名称" prop="name" />
      <el-table-column label="分类字标题" prop="sub_title" />
      <el-table-column align="right">
        <template #header>
            111
          <el-input v-model="search" size="small" placeholder="Type to search" />
        </template>
        <template #default="scope">
          <el-button size="small" @click="handleEdit(scope.$index, scope.row)">
            编辑
          </el-button>
          <el-button
            size="small"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </template>
  
  <script setup>
  import { ref } from 'vue'
  import request from '../../utils/request.js'
  
  const search = ref('')

  const handleEdit = (index, row) => {
    console.log(index, row)
  }
  const handleDelete = (index, row) => {
    console.log(index, row)
  }
  
//非响应式数据
//   let tableData = [
//     {
//       objectId:'ssss',
//       name: 'Tom',
//       sub_title: ['家具'],
//     }
//   ]

//响应式数据
const tableData = ref([])

  request.get('/classes/Category').then(res=>{
    // console.log('get查询结果',res);
    tableData.value = res.data.results  //将后端下发的数据包设置给提前准备好的本地数据包
    console.log(tableData);
  })
  </script>
  